<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.5.0/axios.js"></script>
</head>
<body>
    <button>发送post请求</button>
</body>
<script type="text/javascript">
    const btn = document.getElementsByTagName("button");

    axios.defaults.method="GET";
    axios.defaults.baseURL="http://localhost:3000";
    axios.defaults.params={a:100};
    axios.defaults.timeout=3000;

    btn[0].onclick = function (){
        axios({
            url:"/posts/1"
        }).then(response=>{
            console.log(response);
        })
    }
</script>
</html>